home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 25 / CU Amiga Magazine's Super CD-ROM 25 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-08].iso / CUCD / Programming / QuakeTools / src / libqtools / TDDD.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-11  |  9.6 KB  |  517 lines

  1. #ifndef    TDDD_H
  2. #define    TDDD_H
  3. /*
  4.  * iff
  5.  */
  6.  
  7. struct IFFheader {
  8.   int form;
  9.   int size;
  10.   int type;
  11. };
  12.  
  13. struct IFFchunk {
  14.   int type;
  15.   int size;
  16.   struct IFFchunk *next;
  17.   struct IFFchunk *iter;
  18.   void *data;
  19. };
  20.  
  21. struct IFFdescriptor {
  22.   char *name;
  23. };
  24.  
  25. #define MKID(a,b,c,d) ((a<<24)|(b<<16)|(c<<8)|(d))
  26.  
  27. /* IFF-identifier */
  28. #define ID_FORM MKID('F','O','R','M')
  29.  
  30. /* TDDD-identifier */
  31. #define ID_TDDD MKID('T','D','D','D')
  32.  
  33. /* main-chunks of TDDD */
  34. #define ID_OBJ MKID('O','B','J',' ')
  35.  
  36. /* sub-chunks of OBJ */
  37. #define ID_DESC MKID('D','E','S','C')
  38. #define ID_TOBJ MKID('T','O','B','J')
  39.  
  40. /* sub-sub-chunks of DESC */
  41. #define ID_SHAP MKID('S','H','A','P')
  42. #define ID_SHP2 MKID('S','H','P','2')
  43. #define ID_POSI MKID('P','O','S','I')
  44. #define ID_AXIS MKID('A','X','I','S')
  45. #define ID_SIZE MKID('S','I','Z','E')
  46. #define ID_PNTS MKID('P','N','T','S')
  47. #define ID_PNT2 MKID('P','N','T','2')
  48. #define ID_EDGE MKID('E','D','G','E')
  49. #define ID_EDG2 MKID('E','D','G','2')
  50. #define ID_FACE MKID('F','A','C','E')
  51. #define ID_FAC MKID('F','A','C','')
  52. #define ID_BBOX MKID('B','B','O','X')
  53.  
  54. #define ID_NAME MKID('N','A','M','E')
  55. #define ID_COLR MKID('C','O','L','R')
  56. #define ID_REFL MKID('R','E','F','L')
  57. #define ID_TRAN MKID('T','R','A','N')
  58. #define ID_SPC1 MKID('S','P','C','1')
  59. #define ID_SPC2 MKID('S','P','C','2')
  60. #define ID_INT1 MKID('I','N','T','1')
  61. #define ID_CLST MKID('C','L','S','T')
  62. #define ID_CLS2 MKID('C','L','S','2')
  63. #define ID_RLST MKID('R','L','S','T')
  64. #define ID_RLS2 MKID('R','L','S','2')
  65. #define ID_TLST MKID('T','L','S','T')
  66. #define ID_TLS2 MKID('T','L','S','2')
  67. #define ID_EFLG MKID('E','F','L','G')
  68. #define ID_EFL2 MKID('E','F','L','2')
  69. #define ID_PRP1 MKID('P','R','P','1')
  70. #define ID_PRP2 MKID('P','R','P','2')
  71. #define ID_FOGL MKID('F','O','G','L')
  72. #define ID_FOG2 MKID('F','O','G','2')
  73. #define ID_FOG3 MKID('F','O','G','3')
  74. #define ID_BLB2 MKID('B','L','B','2')
  75. #define ID_PART MKID('P','A','R','T')
  76. #define ID_PAR2 MKID('P','A','R','2')
  77. #define ID_PTFN MKID('P','T','F','N')
  78. #define ID_FGRP MKID('F','G','R','P')
  79. #define ID_FGR2 MKID('F','G','R','2')
  80. #define ID_FGR3 MKID('F','G','R','3')
  81. #define ID_FGR4 MKID('F','G','R','4')
  82. #define ID_BBSG MKID('B','B','S','G')
  83. #define ID_SBSG MKID('S','B','S','G')
  84. #define ID_TXT1 MKID('T','X','T','1')
  85. #define ID_TXT2 MKID('T','X','T','2')
  86. #define ID_TXT3 MKID('T','X','T','3')
  87. #define ID_TXT4 MKID('T','X','T','4')
  88. #define ID_BRS1 MKID('B','R','S','1')
  89. #define ID_BRS2 MKID('B','R','S','2')
  90. #define ID_BRS3 MKID('B','R','S','3')
  91. #define ID_BRS4 MKID('B','R','S','4')
  92. #define ID_BRS5 MKID('B','R','S','5')
  93.  
  94. #define ID_DTOO MKID('D','T','O','O')
  95. #define ID_PTHD MKID('P','T','H','D')
  96. #define ID_PTH2 MKID('P','T','H','2')
  97. #define ID_PTH3 MKID('P','T','H','3')
  98. #define ID_FORD MKID('F','O','R','D')
  99. #define ID_FOR2 MKID('F','O','R','2')
  100. #define ID_FOR3 MKID('F','O','R','3')
  101. #define ID_ANID MKID('A','N','I','D')
  102.  
  103. #define ID_STND MKID('S','T','N','D')
  104. #define ID_STID MKID('S','T','I','D')
  105. #define ID_STDT MKID('S','T','D','T')
  106.  
  107. /*
  108.  * datatypes
  109.  */
  110. typedef signed int    fract;
  111.  
  112. typedef struct {
  113.   unsigned char r, g, b;
  114. } rgb;
  115.  
  116. typedef struct {
  117.   fract x;
  118.   fract y;
  119.   fract z;
  120. } vector;
  121.  
  122. typedef struct {
  123.   vector a;
  124.   vector b;
  125.   vector c;
  126. } matrix;
  127.  
  128. typedef struct {
  129.   vector pos;
  130.   vector xaxis;
  131.   vector yaxis;
  132.   vector zaxis;
  133.   vector size;
  134. } tform;
  135.  
  136. /*
  137.  * structures
  138.  */
  139.  
  140. /* defines for SHAP/SHP2 shape */
  141. #define SH_SPHERE    0
  142. #define SH_STENCI    1
  143. #define SH_AXIS        2
  144. #define SH_FACETS    3
  145. #define SH_SURFAC    4
  146. #define SH_GROUND    5
  147.  
  148. /* defines for SHAP lamp */
  149. #define LP_TYPE    0b000011
  150. #define LP_NOLAMP    0
  151. #define LP_SUN    1
  152. #define LP_FALL    2
  153. #define LP_SHADOW    0b000100
  154. #define LP_SHDWOF    0
  155. #define LP_SHDWON    4
  156. #define LP_FORM    0b011000
  157. #define LP_SPHERE    0
  158. #define LP_CYLIND    8
  159. #define LP_CONICA    16
  160.  
  161. /* defines for SHP2 lamp */
  162. #define LP2_TYPE    0x0003    // 0b00000000000000011
  163. #define LP2_NOLAM    0
  164. #define LP2_POINT    1
  165. #define LP2_PARAL    2
  166. #define LP2_SHAPE    0x000C    //0b00000000000001100
  167. #define LP2_NOSHP    0
  168. #define LP2_ROUND    8
  169. #define LP2_RECTE    12
  170. #define LP2_LENSF    0x0010    //0b00000000000010000
  171. #define LP2_NORMA    0
  172. #define LP2_NOLEN    16
  173. #define LP2_FALLO    0x0060    //0b00000000001100000
  174. #define LP2_NOFAL    0
  175. #define LP2_1RFAL    32
  176. #define LP2_CONTR    64
  177. #define LP2_1R2FA    96
  178. #define LP2_SHADO    0x0080    //0b00000000010000000
  179. #define LP2_SHDOF    0
  180. #define LP2_SHDON    128
  181. #define LP2_SOFTS    0x0100    //0b00000000100000000
  182. #define LP2_SSOFF    0
  183. #define LP2_SSON    256
  184. #define LP2_BRIGH    0x4000    //0b01000000000000000
  185. #define LP2_BROFF    0
  186. #define LP2_BRON    32768
  187.  
  188. struct shap {
  189.   unsigned short int shape, lamp;
  190. };
  191.  
  192. struct posi {
  193.   vector position;
  194. };
  195.  
  196. struct axis {
  197.   vector xaxis, yaxis, zaxis;
  198. };
  199.  
  200. struct size {
  201.   vector size;
  202. };
  203.  
  204. struct points {
  205.   unsigned short int pcount;
  206.   vector points[0];
  207. };
  208.  
  209. struct edges {
  210.   unsigned short int ecount;
  211.   unsigned short int edges[0][2];
  212. };
  213.  
  214. struct faces {
  215.   unsigned short int tcount;
  216.   unsigned short int connects[0][3];
  217. };
  218.  
  219. struct bbox {
  220.   vector mins, maxs;
  221. };
  222.  
  223. struct name {
  224.   char name[18];
  225. };
  226.  
  227. struct colr {
  228.   int color;
  229. };
  230.  
  231. struct refl {
  232.   int reflection;
  233. };
  234.  
  235. struct tran {
  236.   int transparency;
  237. };
  238.  
  239. struct spc1 {
  240.   int specular;
  241.   //char pad;
  242.   //rgb color;
  243. };
  244.  
  245. struct spc2 {
  246.   char pad;
  247.   rgb color;
  248.   fract overdrive;
  249. };
  250.  
  251. struct int1 {
  252.   vector intensity;
  253. };
  254.  
  255. struct faceattr {
  256.   unsigned short int count;
  257.   rgb attr[0];
  258. };
  259.  
  260. #define EDG_FLAGS    0b011000000
  261. #define EDG_QUICK    0b001000000
  262. #define EDG_SHARP    0b010000000
  263.  
  264. struct edgeflags {
  265.   unsigned short int count;
  266.   char flags;
  267. };
  268.  
  269. struct props {
  270.   char dither, hard, rough, shiny, index, quick, phong, genlock;
  271. };
  272.  
  273. struct props2 {
  274.   char bright, hard, rough, shiny, index, quick, phong, genlock;
  275. };
  276.  
  277. struct fog {
  278.   fract length;
  279. };
  280.  
  281. #define FG_TYPE    0b00000000000000011
  282. #define FG_NOFALL    0
  283. #define FG_RAFALL    1
  284. #define FG_AXFALL    2
  285. #define FG_PLFALL    3
  286. #define FG_AXIS    0b00000000000001100
  287. #define FG_XAXIS    0
  288. #define FG_YAXIS    4
  289. #define FG_ZAXIS    8
  290. #define FG_HOTC    0b00000000010000000
  291. #define FG_HOTOFF    0
  292. #define FG_HOTON    128
  293.  
  294. struct fog2 {
  295.   fract length, falloff, hot;
  296.   unsigned short int type;
  297. };
  298.  
  299. struct fog3 {
  300.   fract length, falloff, hot, overdrive;
  301.   unsigned short int type;
  302. };
  303.  
  304. struct blob {
  305.   fract strength, threshold;
  306.   unsigned short int meshdensity;
  307. };
  308.  
  309. #define PRT_TYPE    0b00000000000001111
  310. #define PRT_NOPRT    0
  311. #define PRT_TETRA    1
  312. #define PRT_PYRAM    2
  313. #define PRT_OCTAH    3
  314. #define PRT_CUBES    4
  315. #define PRT_BLOCK    5
  316. #define PRT_DODEC    6
  317. #define PRT_SPHER    7
  318. #define PRT_CENT    0b00000000011110000
  319. #define PRT_INSCR    0
  320. #define PRT_CIRCU    16
  321. #define PRT_INTER    32
  322. #define PRT_BARYC    48
  323. #define PRT_SIZE    0b00000111100000000
  324. #define PRT_SMALL    0
  325. #define PRT_LARGE    256
  326. #define PRT_RANDO    512
  327. #define PRT_SPECI    768
  328. #define PRT_ALIGN    0b01111000000000000
  329. #define PRT_0
  330. #define PRT_4096
  331. #define PRT_8192
  332.  
  333. struct particle {
  334.   unsigned short int type;
  335.   fract size;
  336. };
  337.  
  338. struct particle2 {
  339.   unsigned int type;
  340.   fract part;
  341. };
  342.  
  343. struct particlename {
  344.   char count;
  345.   char name[0];
  346. };
  347.  
  348. struct facesubgroup {
  349.   unsigned short int count;
  350.   char name[18];
  351.   unsigned short int facelist[0];
  352. };
  353.  
  354. struct facesubgroup2 {
  355.   unsigned short int ptype;
  356.   fract psize;
  357.   char count;
  358.   char filename[0];
  359. };
  360.  
  361. struct facesubgroup3 {
  362.   unsigned int ptype;
  363.   fract psize;
  364.   char count;
  365.   char filename[0];
  366. };
  367.  
  368. struct subgroup {
  369.   char subgroup[18];
  370. };
  371.  
  372. #define TXT_FLAGS    0b00000000000000111
  373. #define TXT_CHILD    0
  374. #define TXT_LIGHT    1
  375. #define TXT_DISAB    2
  376. #define TPT_FLAGS    0b00000000000111111
  377. #define TPT_RED        0
  378. #define TPT_GREEN    1
  379. #define TPT_BLUE    2
  380. #define TPT_SCALE    3
  381. #define TPT_UNUSE    4
  382. #define TPT_LUNUS    5
  383.  
  384. struct texture {
  385.   unsigned short int flags;
  386.   tform tform;
  387.   fract params[16];
  388.   char pflags[16];
  389.   char length;
  390.   char name[0];
  391. };
  392.  
  393. struct texture2 {
  394.   unsigned short int flags;
  395.   tform tform;
  396.   fract params[16];
  397.   char pflags[16];
  398.   char subgrp[18];
  399.   char length;
  400.   char name[0];
  401. };
  402.  
  403. struct texture3 {
  404.   unsigned short int flags;
  405.   tform tform;
  406.   fract params[16];
  407.   char pflags[16];
  408.   char subgrp[18];
  409.   char stname[18];
  410.   char length;
  411.   char name[0];
  412. };
  413.  
  414. struct texture4 {
  415.   unsigned short int flags;
  416.   tform tform;
  417.   fract params[16];
  418.   char pflags[16];
  419.   char subgrp[18];
  420.   char stname[18];
  421.   char label[18];
  422.   fract mixing;
  423.   char length;
  424.   char name[0];
  425. };
  426.  
  427. #define BRS_FLAGS    0x0F    //0b000001111
  428. #define BRS_COLOR    0
  429. #define BRS_REFLE    1
  430. #define BRS_FILTE    2
  431. #define BRS_ALTIT    3
  432. #define BRS_ENVRE    4
  433. #define BRS_SPECU    5
  434. #define BRS_HARDN    6
  435. #define BRS_ROUGH    7
  436. #define BRS_FOGLE    8
  437. #define BRS_SHINI    9
  438. #define BRS_BRIGH    10
  439. #define BRS_INDEX    11
  440. #define BRS_LIGHT    12
  441. #define BRW_FLAGS    0x7F    //0b011111111
  442. #define BRW_X        1
  443. #define BRW_Y        2
  444. #define BRW_CHILD    4
  445. #define BRW_REPEA    8
  446. #define BRW_FLIP    16
  447. #define BRW_INVER    32
  448. #define BRW_ZEROC    64
  449. #define BRW_DISAB    128
  450.  
  451. #if 0
  452. struct brush {
  453.   unsigned short int flags, wflags;
  454.   tform tform;
  455.   char length;
  456.   char name[0];
  457. };
  458. #endif
  459.  
  460. struct brush2 {
  461.   unsigned short int flags, wflags;
  462.   tform tform;
  463.   unsigned short int fullscale, maxseq;
  464.   char length;
  465.   char name[0];
  466. };
  467.  
  468. struct brush3 {
  469.   unsigned short int flags, wflags;
  470.   tform tform;
  471.   unsigned short int fullscale, maxseq;
  472.   char subgrp[18];
  473.   char length;
  474.   char name[0];
  475. };
  476.  
  477. struct brush4 {
  478.   unsigned short int flags, wflags;
  479.   tform tform;
  480.   unsigned short int fullscale, maxseq;
  481.   char subgrp[18];
  482.   char stname[18];
  483.   char length;
  484.   char name[0];
  485. };
  486.  
  487. struct brush5 {
  488.   unsigned short int flags, wflags;
  489.   tform tform;
  490.   unsigned short int fullscale, maxseq;
  491.   char subgrp[18];
  492.   char stname[18];
  493.   char label[18];
  494.   fract mixing, foglo, foghi;
  495.   char length;
  496.   char name[0];
  497. };
  498.  
  499. /*
  500.  * tools
  501.  */
  502. static __inline fract float2fract(float number);
  503. static __inline float fract2float(fract number);
  504.  
  505. static __inline fract float2fract(float number) {
  506.   if(number < 0)
  507.     return -(int)(-65536.0 * number + 0.5);
  508.   else
  509.     return (int)(65536.0 * number + 0.5);
  510. }
  511.  
  512. static __inline float fract2float(fract number) {
  513.   return number / 65536.0;
  514. }
  515.  
  516. #endif
  517.